package com.ssyc.gsk_teacher.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ssyc.common.adapter.CommonAdapter;
import com.ssyc.common.adapter.ViewHolder;
import com.ssyc.gsk_teacher.R;
import com.ssyc.gsk_teacher.bean.SyllabusInfo;
import com.ssyc.gsk_teacher.bean.UnitBean;

import java.util.List;


/**
 * 教师端--展示单元下所有课程的列表适配器
 * Created by Administrator on 2018/1/22 0022.
 */

public class TeacherGvLessonSyllabusAdapter extends CommonAdapter<UnitBean.DataBean.GradeListBean> {
    public List<SyllabusInfo.ListBean> list;
    private Context context;

    public TeacherGvLessonSyllabusAdapter(Context context, List<UnitBean.DataBean.GradeListBean> datas, int layoutId, List<SyllabusInfo.ListBean> list) {
        super(context, datas, layoutId);
        this.list = list;
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, UnitBean.DataBean.GradeListBean lessonInfo) {
        //课程名称
        TextView tvChildren = holder.getView(R.id.tv_children);
        boolean isSyll = false;
        if (list != null && list.size() != 0) {

            for (int i = 0; i < list.size(); i++) {
                //遍历判断当前单元是否为上过的课程
                if (lessonInfo.getLesson_id().equals(list.get(i).getLesson() + "")) {
                    isSyll = true;
                }
            }
        }
        if (isSyll) {
            //已上过的课程
            tvChildren.setTextColor(context.getResources().getColor(R.color.white));
            tvChildren.setBackground(context.getResources().getDrawable(R.drawable.teacher_lesson_bg));
        } else {
            //未上过的课程
            tvChildren.setTextColor(context.getResources().getColor(R.color.green));
            tvChildren.setBackground(context.getResources().getDrawable(R.drawable.teacher_lesson_wirte_bg));
        }
        tvChildren.setText("Lesson" + lessonInfo.getLesson_id());
        //课程的标记信息
        TextView tvNum = holder.getView(R.id.tv_lesson_num);
        tvNum.setVisibility(View.GONE);

    }
}
